package com.nkzy.mapper;


import com.nkzy.pojo.Address;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AddressMapper  {
    // 继承了BaseMapper，已经包含了基本的CRUD操作

    // 如果需要自定义SQL，可以在这里添加方法
    @Select("SELECT * FROM address WHERE id = #{id}")
    Address selectById(@Param("id") Long id);

    // 新增：查询所有地址的方法
    @Select("SELECT * FROM address")
    List<Address> selectAll();

    // 新增：根据多个id查询地址的方法
    @Select("<script>" +
            "SELECT * FROM address WHERE id IN " +
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    List<Address> selectByIds(@Param("ids") List<Long> ids);

    void updateAddress(Address addr);
}